﻿Public Class RproformaCabecera

    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.SeleccionarXEstado(descEmpresa)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                'If DisplaySelect Then proformas.Insert(0, New EproformaCabecera("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera, ByRef idProforma As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaCabecera.Añadir(descEmpresa, pProformaCabecera, idProforma)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirVersus(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera, ByRef idProforma As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaCabecera.AñadirVersus(descEmpresa, pProformaCabecera, idProforma)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera, ByRef idProforma As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaCabecera.Editar(descEmpresa, pProformaCabecera, idProforma)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarVersus(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera, ByRef idProforma As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaCabecera.EditarVersus(descEmpresa, pProformaCabecera, idProforma)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DproformaCabecera.Eliminar(descEmpresa, pProformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Filtrar(ByVal descEmpresa As String, ByVal pProfoma As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.Filtrar(descEmpresa, pProfoma)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    Public Shared Function FiltrarCtrl(ByVal descEmpresa As String, ByVal pProfoma As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.FiltrarCtrl(descEmpresa, pProfoma)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    Public Shared Function FiltrarConsultaCtrl(ByVal descEmpresa As String, ByVal pProfoma As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.FiltrarConsultaCtrl(descEmpresa, pProfoma)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function

    '-------    MENU REPORTE    ------------'
    Public Shared Function Reporte(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.ReporteProforma(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    '-------    CONSULTA PROFORMA    ------------'
    Public Shared Function ConsultaProforma(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.ConsultaProforma(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    '-------    CONSULTA PROFORMA MODULO    ------------'
    Public Shared Function ConsultaProformaModulo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.ConsultaProformaModulo(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function

    '-------    MENU REPORTE EVOLTA / VERSUS    ------------'
    Public Shared Function ReporteXEmpresa(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.ReporteProformaXEmpresa(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    Public Shared Function ReporteXVersus(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.ReporteProformaXVersus(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function

    '-------   MENU ATENCION CLIENTE  ------'
    Public Shared Function SeleccionarXPosCliente(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.SeleccionarXPosCliente(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function

    '-------   MENU ATENCION CLIENTE VERSUS ------'
    Public Shared Function SeleccionarXPosClienteXVersus(ByVal descEmpresa As String, ByVal pProformaCabecera As EproformaCabecera) As List(Of EproformaCabecera)
        Dim proformas As List(Of EproformaCabecera) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proformas = DproformaCabecera.SeleccionarXPosClienteXVersus(descEmpresa, pProformaCabecera)
                If proformas Is Nothing Then proformas = New List(Of EproformaCabecera)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proformas
    End Function
    '---------------------------------------'

End Class
